import { PackageManagerTabs } from 'rspress/theme';

# Quick Start

## Installation

Open a Terminal in your project's folder and run:

<PackageManagerTabs
  command={{
    yarn: 'yarn add -D @testing-library/react-native',
    npm: 'npm install -D @testing-library/react-native',
  }}
/>

This library has a peer dependency for `react-test-renderer` package. Make sure that your `react-test-renderer` version matches exactly your `react` version.

### Jest matchers

To set up React Native-specific Jest matchers, add the following line to your `jest-setup.ts` file (configured using [`setupFilesAfterEnv`](https://jestjs.io/docs/configuration#setupfilesafterenv-array)):

```ts title=jest-setup.ts
import '@testing-library/react-native/extend-expect';
```

### ESLint plugin

We recommend setting up [`eslint-plugin-testing-library`](https://github.com/testing-library/eslint-plugin-testing-library) package to help you avoid common Testing Library mistakes and bad practices.

Install the plugin (assuming you already have `eslint` installed & configured):

<PackageManagerTabs
  command={{
    yarn: 'yarn add -D eslint-plugin-testing-library',
    npm: 'npm install -D eslint-plugin-testing-library',
  }}
/>

Then, add relevant entry to your ESLint config (e.g., `.eslintrc.js`). We recommend extending the `react` plugin:

```js title=.eslintrc.js
module.exports = {
  overrides: [
    {
      // Test files only
      files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
      extends: ['plugin:testing-library/react'],
    },
  ],
};
```
